﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

///<Summary>
///Thanks to David Amador, once again and David Gouveia :)
///</Summary>


namespace Imagine
{
    public class Camera
    {
        #region Private_Parts
        Vector3         m_origin;
        Viewport        m_viewport;
        Vector3         m_position;
        float           m_rotation;
        float           m_xScale, m_yScale;
        float           m_parallaxFactor;
        #endregion

        #region Properties
        public Vector3 Position
        {
            get { return m_position;    }
            set { m_position = value;   }
        }

        public float Rotation
        {
            get { return m_rotation;    }
            set { m_rotation = value;   }
        }
        
        public float ParallaxFactor
        {
            get { return m_parallaxFactor;  }
            set { m_parallaxFactor = value; }
        }

        public float ScaleX
        {
            get { return m_xScale;  }
            set { m_xScale = value; }
        }
        public float ScaleY
        {
            get { return m_yScale;  }
            set { m_yScale = value; }
        }
        #endregion

        public Camera(GraphicsDevice _device)
        {
            m_viewport = _device.Viewport;
            m_origin = new Vector3(_device.Viewport.Width/2, _device.Viewport.Height/2, 0.0f);
            m_xScale = 1.0f;
            m_yScale = 1.0f;
        }

        public Matrix GetTransformation()
        {
            return Matrix.CreateTranslation(-m_position * m_parallaxFactor) *
                                            //Matrix.CreateTranslation(-m_origin) *
                                            Matrix.CreateRotationZ(m_rotation) *
                                            Matrix.CreateScale(m_xScale,m_yScale,1.0f) *
                                            Matrix.CreateTranslation(m_origin);
        }
    }

}